﻿/**
 * Reboulder - Partial Boulder Dash clone
 * Jesús Sagra, 2014
 * 
 * Player class: sprite used by real players
 * 
 * Version    Date     Changes
 * -----------------------------------------------------
 *  0.01   07-dic-2014  Constructor, movement.
 *  0.02   11-dic-2014  Player death, lives-- , restart position.
 */

class Player : Sprite
{
    protected byte lives;
    protected int startX, startY;

    public Player(int posX, int posY)
        : base(posX, posY)
    {
        lives = 3;
        startX = x;
        startY = y;
        this.x = x;
        this.y = y;
        
        height = width = 32;
        image = new Image("data/player.png");
        speed = 32;
        visible = true;
    }

   
    public void SetLives(byte newLives)
    {
        lives = newLives;
    }

    public byte GetLives()
    {
        return lives;
    }
    public void MoveRight()
    {
        x += speed;
    }

    public void MoveLeft()
    {
        x -= speed;
    }

    public void MoveUp()
    {
        y -= speed;
    }

    public void MoveDown()
    {
        y += speed;
    }

    //Payer death
    public void Death()
    {
        lives--;
        x = startX;
        y = startY;
    }

    public override string ToString()
    {
        return "player";
    }
}